﻿using MyBasicLib.Data;
using MyBasicLib.Data.ORMLiteNew;
using MyBasicLib.Utilities;
using MyBasicLib.Utilities.Log;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;

namespace MyBasicLib
{
    internal class Startup
    {
        static string loggerPath = "MyBasicLib\\Log";
        static string connectionStrings = "MySqlConnection";
        public static void InitIOC()
        {
            IOC.DefaultContainer.Register<ILogger>(() =>
            {
                ILogger logger = new FileLogger(loggerPath, LogLevel.Error);
                return logger;
            }, true);

            IOC.DefaultContainer.Register<IDatabase>(() =>
            {
                IDatabase db = new Data.SqlClient.Database(ConfigurationManager.ConnectionStrings[connectionStrings].ConnectionString);
                return db;
            });
            IOC.DefaultContainer.Register<IMappingProvider>(() =>
            {
                IMappingProvider obj = new AttributeMappingProvider();
                return obj;
            });
            IOC.DefaultContainer.Register<IDbQueryProvider>(() =>
            {
                IDbQueryProvider obj = new MyBasicLib.Data.ORMLiteNew.SqlClient.DbQueryProvider();
                return obj;
            });

        }
    }
}
